#ifndef GAMESCENE_H
#define GAMESCENE_H

#include <QWidget>
#include <QObject>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGLWidget>
#include <QGLFormat>
#include <QApplication>
#include <QTime>

#include "graphicspanview.h"

// This class is designed to be inherited by a class representing
// a scene in the game.

class GameScene : public QWidget
{
    Q_OBJECT

public:
    GameScene(QWidget *parent = 0);

    enum SceneState {stopped = 0,
                     playing = 1,
                     paused = 2};

    enum GameScenes {noScene = -2,
                     endGame = -1,
                     previousScene = 0,      // These represent the scenes in the game
                     menuScene = 1,          // There are here so they can be reurned by end()
                     helpScene = 2,          // so the games knows the next scene to play. -1 is
                     levelSceneTutorial = 3, // always end game.
                     levelScene1 = 4,
                     levelScene2 = 5,
                     levelScene3 = 6};

    GraphicsPanView * mainView;

    void pauseScene();
    void resumeScene();

public slots:
    void startScene();     //Starts the timer to update the scene. Call this
                           //function when the scene starts.

    void endScene(GameScene::GameScenes nextScene);    // Stops the scene updats and hides the graphics
                                                       // view. Call this function when the scene is over.

    void focusChanged(QWidget * old, QWidget * now);

signals:
    void end(GameScene::GameScenes nextScene);


protected:
    virtual void start();   //Reimpliment this to run code when the scene is started
    void timerEvent(QTimerEvent *event);
    
    int speed;
    QGraphicsScene * mainScene;
    QGLWidget * GLWidget;

private:
    QTime time;

    SceneState state;
    int updateTimerId;  // Keeps track of the timer id for the update timer so we can
                            // kill it at the end of the scene
};

#endif // GAMESCENE_H
